package demo;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: syyyy
 * Date: 2025-07-04
 * Time: 12:22
 */
public class Test {
    public static void main(String[] args) {
        Animal animal=new Bird("dudu",1);
    }

    public static void main3(String[] args) {
        Animal animal=new Bird("lala",2);

        Bird bird=(Bird)animal;

        bird.fly();
    }
    public static void func(Animal animal){
        animal.fly();
    }

    public static void main2(String[] args) {
        Dog dog=new Dog("拉拉",1);
        func(dog);
    }
    public static void main1(String[] args) {
        Animal animal=new Dog("多多",2);
        animal.eat();//第一种向上转型的方法
    }
}
